<HTML><HEAD><META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type"/><TITLE>EMMA Coverage Report</TITLE><STYLE TYPE="text/css"> TABLE,TD,TH {border-style:solid; border-color:black;} TD,TH {background:white;margin:0;line-height:100%;padding-left:0.5em;padding-right:0.5em;} TD {border-width:0 1px 0 0;} TH {border-width:1px 1px 1px 0;} TR TD.h {color:red;} TABLE {border-spacing:0; border-collapse:collapse;border-width:0 0 1px 1px;} P,H1,H2,H3,TH {font-family:verdana,arial,sans-serif;font-size:10pt;} TD {font-family:courier,monospace;font-size:10pt;} TABLE.hdft {border-spacing:0;border-collapse:collapse;border-style:none;} TABLE.hdft TH,TABLE.hdft TD {border-style:none;line-height:normal;} TABLE.hdft TH.tl,TABLE.hdft TD.tl {background:#6699CC;color:white;} TABLE.hdft TD.nv {background:#6633DD;color:white;} .nv A:link {color:white;} .nv A:visited {color:white;} .nv A:active {color:yellow;} TABLE.hdft A:link {color:white;} TABLE.hdft A:visited {color:white;} TABLE.hdft A:active {color:yellow;} .in {color:#356085;} TABLE.s TD {padding-left:0.25em;padding-right:0.25em;} TABLE.s TD.l {padding-left:0.25em;padding-right:0.25em;text-align:right;background:#F0F0F0;} TABLE.s TR.z TD {background:#FF9999;} TABLE.s TR.p TD {background:#FFFF88;} TABLE.s TR.c TD {background:#CCFFCC;} A:link {color:#0000EE;text-decoration:none;} A:visited {color:#0000EE;text-decoration:none;} A:hover {color:#0000EE;text-decoration:underline;} TABLE.cn {border-width:0 0 1px 0;} TABLE.s {border-width:1px 0 1px 1px;} TD.h {color:red;border-width:0 1px 0 0;} TD.f {border-width:0 1px 0 1px;} TD.hf {color:red;border-width:0 1px 0 1px;} TH.f {border-width:1px 1px 1px 1px;} TR.cis TD {background:#F0F0F0;} TR.cis TD {border-width:1px 1px 1px 0;} TR.cis TD.h {color:red;border-width:1px 1px 1px 0;} TR.cis TD.f {border-width:1px 1px 1px 1px;} TR.cis TD.hf {color:red;border-width:1px 1px 1px 1px;} TD.b {border-style:none;background:transparent;line-height:50%;}  TD.bt {border-width:1px 0 0 0;background:transparent;line-height:50%;} TR.o TD {background:#F0F0F0;}TABLE.it {border-style:none;}TABLE.it TD,TABLE.it TH {border-style:none;}</STYLE></HEAD><BODY><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="tl"><A HREF="http://www.eclemma.org/">EMMA</A> Coverage Report (generated Wed Nov 23 14:11:57 CET 2011)</TH></TR><TR><TD CLASS="nv">[<A HREF="../Cobertura.html">all classes</A>][<A HREF="3.html">es.citic.puedes.weatherservice.impl</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">WeatherManagerImpl.java</SPAN>]</H2><TABLE CELLSPACING="0" WIDTH="100%"><TR><TH>name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD>WeatherManagerImpl.java</TD><TD>100% (1/1)</TD><TD>94%  (16/17)</TD><TD>87%  (1196/1367)</TD><TD>84%  (254,4/303)</TD></TR></TABLE><H3>COVERAGE BREAKDOWN BY CLASS AND METHOD</H3><TABLE CLASS="cn" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="f">name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD></TR><TR CLASS="cis"><TD CLASS="f">class <A HREF="#0">WeatherManagerImpl</A></TD><TD>100% (1/1)</TD><TD>94%  (16/17)</TD><TD>87%  (1196/1367)</TD><TD>84%  (254,4/303)</TD></TR><TR><TD CLASS="f"><A HREF="#1">WeatherManagerImpl (String): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/15)</TD><TD CLASS="h">0%   (0/2)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">getByte (byte): byte</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">57%  (28/49)</TD><TD CLASS="h">30%  (6/20)</TD></TR><TR><TD CLASS="f"><A HREF="#3">getIcon (String): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">64%  (65/102)</TD><TD CLASS="h">55%  (12/22)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#4">getStringWithOneSpace (String): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">76%  (85/112)</TD><TD>83%  (17,4/21)</TD></TR><TR><TD CLASS="f"><A HREF="#5">getCurrentCondition (ConditionData, Language): Weather</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>86%  (146/170)</TD><TD>85%  (35/41)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#6">getDataLocation (String): LocationResponse</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>89%  (108/122)</TD><TD>86%  (19/22)</TD></TR><TR><TD CLASS="f"><A HREF="#7">getWeather (WeatherData, Language): Weather</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>89%  (110/123)</TD><TD>91%  (30/33)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#8">getCountry (RequestData): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>90%  (19/21)</TD><TD>86%  (6/7)</TD></TR><TR><TD CLASS="f"><A HREF="#9">getLocation (RequestData): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>90%  (19/21)</TD><TD>86%  (6/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#a">setPreferences (String, String, Integer): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>92%  (60/65)</TD><TD>85%  (11/13)</TD></TR><TR><TD CLASS="f"><A HREF="#b">getDataWeather (String, String, int): WeatherResponse</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>93%  (142/153)</TD><TD>91%  (29/32)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#0">&lt;static initializer&gt;</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (4/4)</TD><TD>100% (2/2)</TD></TR><TR><TD CLASS="f"><A HREF="#d">WeatherManagerImpl (String, WeatherDataBase): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (41/41)</TD><TD>100% (9/9)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#e">getLocation (String): List</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (127/127)</TD><TD>100% (29/29)</TD></TR><TR><TD CLASS="f"><A HREF="#f">getPreferences (Integer, Language): List</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (31/31)</TD><TD>100% (7/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#10">getUnicodeLocation (String): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (70/70)</TD><TD>100% (14/14)</TD></TR><TR><TD CLASS="f"><A HREF="#11">getWeather (String, String, int, Language, Integer): WeatherCondition</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (141/141)</TD><TD>100% (22/22)</TD></TR></TABLE><P></P><TABLE CLASS="s" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="l">1</TD><TD>package es.citic.puedes.weatherservice.impl;</TD></TR><TR><TD CLASS="l">2</TD><TD> </TD></TR><TR><TD CLASS="l">3</TD><TD>/*</TD></TR><TR><TD CLASS="l">4</TD><TD> *</TD></TR><TR><TD CLASS="l">5</TD><TD> * WeatherManagerImpl</TD></TR><TR><TD CLASS="l">6</TD><TD> *</TD></TR><TR><TD CLASS="l">7</TD><TD> * This class is the implementation of WeatherManager.</TD></TR><TR><TD CLASS="l">8</TD><TD> *</TD></TR><TR><TD CLASS="l">9</TD><TD> * Copyright 2008-2009 Centro Andaluz de InnovaciÃ³n y TecnologÃ­as de la</TD></TR><TR><TD CLASS="l">10</TD><TD> * InformaciÃ³n y las Comunicaciones (CITIC). All Rights Reserved.</TD></TR><TR><TD CLASS="l">11</TD><TD> * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER</TD></TR><TR><TD CLASS="l">12</TD><TD> *</TD></TR><TR><TD CLASS="l">13</TD><TD> * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque</TD></TR><TR><TD CLASS="l">14</TD><TD> * TecnolÃ³gico de AndalucÃ­a 29590 - Campanillas, MÃ¡laga, Spain</TD></TR><TR><TD CLASS="l">15</TD><TD> * or visit www.citic.es, if you need additional information or</TD></TR><TR><TD CLASS="l">16</TD><TD> * have any questions.</TD></TR><TR><TD CLASS="l">17</TD><TD> */</TD></TR><TR><TD CLASS="l">18</TD><TD> </TD></TR><TR><TD CLASS="l">19</TD><TD>import java.io.BufferedReader;</TD></TR><TR><TD CLASS="l">20</TD><TD>import java.io.IOException;</TD></TR><TR><TD CLASS="l">21</TD><TD>import java.io.InputStream;</TD></TR><TR><TD CLASS="l">22</TD><TD>import java.io.InputStreamReader;</TD></TR><TR><TD CLASS="l">23</TD><TD>import java.net.HttpURLConnection;</TD></TR><TR><TD CLASS="l">24</TD><TD>import java.net.URL;</TD></TR><TR><TD CLASS="l">25</TD><TD>import java.text.ParseException;</TD></TR><TR><TD CLASS="l">26</TD><TD>import java.text.SimpleDateFormat;</TD></TR><TR><TD CLASS="l">27</TD><TD>import java.util.ArrayList;</TD></TR><TR><TD CLASS="l">28</TD><TD>import java.util.Calendar;</TD></TR><TR><TD CLASS="l">29</TD><TD>import java.util.Date;</TD></TR><TR><TD CLASS="l">30</TD><TD>import java.util.GregorianCalendar;</TD></TR><TR><TD CLASS="l">31</TD><TD>import java.util.List;</TD></TR><TR><TD CLASS="l">32</TD><TD> </TD></TR><TR><TD CLASS="l">33</TD><TD>import org.codehaus.jackson.map.ObjectMapper;</TD></TR><TR><TD CLASS="l">34</TD><TD>import org.slf4j.Logger;</TD></TR><TR><TD CLASS="l">35</TD><TD>import org.slf4j.LoggerFactory;</TD></TR><TR><TD CLASS="l">36</TD><TD> </TD></TR><TR><TD CLASS="l">37</TD><TD>import es.citic.puedes.weatherservice.IWeatherManager;</TD></TR><TR><TD CLASS="l">38</TD><TD>import es.citic.puedes.weatherservice.WeatherException;</TD></TR><TR><TD CLASS="l">39</TD><TD>import es.citic.puedes.weatherservice.impl.bbdd.WeatherDataBase;</TD></TR><TR><TD CLASS="l">40</TD><TD>import es.citic.puedes.weatherservice.impl.umm.WeatherUserModelImpl;</TD></TR><TR><TD CLASS="l">41</TD><TD>import es.citic.puedes.weatherservice.model.Language;</TD></TR><TR><TD CLASS="l">42</TD><TD>import es.citic.puedes.weatherservice.model.Location;</TD></TR><TR><TD CLASS="l">43</TD><TD>import es.citic.puedes.weatherservice.model.Temperature;</TD></TR><TR><TD CLASS="l">44</TD><TD>import es.citic.puedes.weatherservice.model.Weather;</TD></TR><TR><TD CLASS="l">45</TD><TD>import es.citic.puedes.weatherservice.model.WeatherCondition;</TD></TR><TR><TD CLASS="l">46</TD><TD>import es.citic.puedes.weatherservice.model.Wind;</TD></TR><TR><TD CLASS="l">47</TD><TD>import es.citic.puedes.weatherservice.umm.IWeatherUserModel;</TD></TR><TR><TD CLASS="l">48</TD><TD>import es.citic.puedes.weatherservice.umm.WeatherPreferences;</TD></TR><TR><TD CLASS="l">49</TD><TD>import es.citic.puedes.weatherservice.utils.DataConfigManager;</TD></TR><TR><TD CLASS="l"><A NAME="0">50</A></TD><TD>import es.citic.puedes.weatherservice.utils.Utils;</TD></TR><TR><TD CLASS="l">51</TD><TD>import es.citic.puedes.weatherservice.utils.XmlManager;</TD></TR><TR><TD CLASS="l">52</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">53</TD><TD>public class WeatherManagerImpl implements IWeatherManager {        </TD></TR><TR CLASS="c"><TD CLASS="l">54</TD><TD>        private static Logger logger = LoggerFactory.getLogger(WeatherManagerImpl.class);        </TD></TR><TR><TD CLASS="l">55</TD><TD>        </TD></TR><TR CLASS="c"><TD CLASS="l">56</TD><TD>        private String key = &#34;&#34;;  </TD></TR><TR CLASS="c"><TD CLASS="l">57</TD><TD>        public String domain= &#34;&#34;;//&#34;free.worldweatheronline.com&#34;;</TD></TR><TR><TD CLASS="l">58</TD><TD>        private WeatherDataBase weatherDB;</TD></TR><TR><TD CLASS="l"><A NAME="1">59</A></TD><TD>        private XmlManager xmlManager; </TD></TR><TR><TD CLASS="l">60</TD><TD> </TD></TR><TR><TD CLASS="l">61</TD><TD> </TD></TR><TR><TD CLASS="l"><A NAME="d">62</A></TD><TD>        public WeatherManagerImpl(String configFile) {</TD></TR><TR CLASS="z"><TD CLASS="l">63</TD><TD>                this(configFile,new WeatherDataBase(new DataConfigManager(configFile).getValueFromConfigXml(&#34;weathermanager&#34;, &#34;constants&#34;, &#34;persistence_unit&#34;)));</TD></TR><TR CLASS="z"><TD CLASS="l">64</TD><TD>        }</TD></TR><TR><TD CLASS="l">65</TD><TD>        </TD></TR><TR CLASS="c"><TD CLASS="l">66</TD><TD>        public WeatherManagerImpl(String configFile,WeatherDataBase weatherDataBase) {</TD></TR><TR CLASS="c"><TD CLASS="l">67</TD><TD>                DataConfigManager dcm = new DataConfigManager(configFile);</TD></TR><TR><TD CLASS="l">68</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">69</TD><TD>                xmlManager = new XmlManager(dcm.getValueFromConfigXml(&#34;weathermanager&#34;, &#34;config&#34;, &#34;config_file&#34;));</TD></TR><TR CLASS="c"><TD CLASS="l">70</TD><TD>                weatherDB = weatherDataBase;</TD></TR><TR CLASS="c"><TD CLASS="l">71</TD><TD>                domain = dcm.getValueFromConfigXml(&#34;weathermanager&#34;, &#34;config&#34;, &#34;domain&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">72</TD><TD>                key = dcm.getValueFromConfigXml(&#34;weathermanager&#34;, &#34;config&#34;, &#34;key&#34;);                </TD></TR><TR CLASS="c"><TD CLASS="l">73</TD><TD>        }</TD></TR><TR><TD CLASS="l"><A NAME="e">74</A></TD><TD>        </TD></TR><TR><TD CLASS="l">75</TD><TD> </TD></TR><TR><TD CLASS="l">76</TD><TD>        @Override</TD></TR><TR><TD CLASS="l">77</TD><TD>        public List&lt;Location&gt; getLocation(String location) throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">78</TD><TD>                logger.debug(&#34;Enter: getLocation (&#34; + location + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">79</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">80</TD><TD>                if (location != null &amp;&amp; !location.trim().isEmpty()) {</TD></TR><TR CLASS="c"><TD CLASS="l">81</TD><TD>                        List&lt;Location&gt; locationList = new ArrayList&lt;Location&gt;();</TD></TR><TR CLASS="c"><TD CLASS="l">82</TD><TD>                        location = getUnicodeLocation(location);</TD></TR><TR><TD CLASS="l">83</TD><TD> </TD></TR><TR><TD CLASS="l">84</TD><TD>                        // Get locations</TD></TR><TR CLASS="c"><TD CLASS="l">85</TD><TD>                        LocationResponse locationResponse = getDataLocation(location);</TD></TR><TR><TD CLASS="l">86</TD><TD> </TD></TR><TR><TD CLASS="l">87</TD><TD>                        // Map locations in Location list object</TD></TR><TR CLASS="c"><TD CLASS="l">88</TD><TD>                        LocationData[] locationArray = locationResponse.getSearch_api()</TD></TR><TR CLASS="c"><TD CLASS="l">89</TD><TD>                                        .getResult();</TD></TR><TR CLASS="c"><TD CLASS="l">90</TD><TD>                        for (int i = 0; i &lt; locationArray.length; i++) {</TD></TR><TR CLASS="c"><TD CLASS="l">91</TD><TD>                                Location newLocation = null;</TD></TR><TR CLASS="c"><TD CLASS="l">92</TD><TD>                                LocationData locationData = locationArray[i];</TD></TR><TR CLASS="c"><TD CLASS="l">93</TD><TD>                                Value[] areaName = locationData.getAreaName();</TD></TR><TR CLASS="c"><TD CLASS="l">94</TD><TD>                                Value[] region = locationData.getRegion();</TD></TR><TR CLASS="c"><TD CLASS="l">95</TD><TD>                                Value[] country = locationData.getCountry();</TD></TR><TR CLASS="c"><TD CLASS="l">96</TD><TD>                                if (region != null) {</TD></TR><TR CLASS="c"><TD CLASS="l">97</TD><TD>                                        String nameLocation = areaName[0].getValue() + &#34;, &#34;</TD></TR><TR CLASS="c"><TD CLASS="l">98</TD><TD>                                                        + region[0].getValue();</TD></TR><TR CLASS="c"><TD CLASS="l">99</TD><TD>                                        newLocation = new Location(nameLocation,</TD></TR><TR CLASS="c"><TD CLASS="l">100</TD><TD>                                                        country[0].getValue(), locationData.getLatitude(),</TD></TR><TR CLASS="c"><TD CLASS="l">101</TD><TD>                                                        locationData.getLongitude(),</TD></TR><TR CLASS="c"><TD CLASS="l">102</TD><TD>                                                        locationData.getPopulation());</TD></TR><TR CLASS="c"><TD CLASS="l">103</TD><TD>                                        locationList.add(newLocation);</TD></TR><TR><TD CLASS="l">104</TD><TD>                                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">105</TD><TD>                                        newLocation = new Location(areaName[0].getValue(),</TD></TR><TR CLASS="c"><TD CLASS="l">106</TD><TD>                                                        country[0].getValue(), locationData.getLatitude(),</TD></TR><TR CLASS="c"><TD CLASS="l">107</TD><TD>                                                        locationData.getLongitude(),</TD></TR><TR CLASS="c"><TD CLASS="l">108</TD><TD>                                                        locationData.getPopulation());</TD></TR><TR CLASS="c"><TD CLASS="l">109</TD><TD>                                        locationList.add(newLocation);</TD></TR><TR><TD CLASS="l">110</TD><TD>                                }</TD></TR><TR><TD CLASS="l">111</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">112</TD><TD>                        logger.debug(&#34;Exit: getLocation()&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">113</TD><TD>                        return locationList;</TD></TR><TR><TD CLASS="l">114</TD><TD>                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">115</TD><TD>                        throw new WeatherException(&#34;Location is empty&#34;);</TD></TR><TR><TD CLASS="l">116</TD><TD>                }</TD></TR><TR><TD CLASS="l">117</TD><TD>        }</TD></TR><TR><TD CLASS="l">118</TD><TD> </TD></TR><TR><TD CLASS="l">119</TD><TD>        /*</TD></TR><TR><TD CLASS="l">120</TD><TD>         * (non-Javadoc)</TD></TR><TR><TD CLASS="l">121</TD><TD>         * </TD></TR><TR><TD CLASS="l">122</TD><TD>         * @see</TD></TR><TR><TD CLASS="l">123</TD><TD>         * es.citic.puedes.weatherservice.IWeatherManager#getWeather(java.lang.String</TD></TR><TR><TD CLASS="l"><A NAME="11">124</A></TD><TD>         * , java.lang.String, int, es.citic.puedes.core.usermanager.IUser)</TD></TR><TR><TD CLASS="l">125</TD><TD>         */</TD></TR><TR><TD CLASS="l">126</TD><TD>        @Override</TD></TR><TR><TD CLASS="l">127</TD><TD>        public WeatherCondition getWeather(String name, String country, int days, Language language, Integer user) throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">128</TD><TD>                logger.debug(&#34;Enter: getWeather(&#34; + name + &#34;,&#34; + country + &#34;,&#34; + days + &#34;,&#34; + language + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">129</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">130</TD><TD>                WeatherCondition weatherCondition = null;</TD></TR><TR CLASS="c"><TD CLASS="l">131</TD><TD>                if ((name == null || name.trim().isEmpty()) || (country == null || country.trim().isEmpty())) {</TD></TR><TR CLASS="c"><TD CLASS="l">132</TD><TD>                        throw new WeatherException(&#34;Location is empty&#34;);</TD></TR><TR><TD CLASS="l">133</TD><TD>                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">134</TD><TD>                        if ((days &gt;= 1) &amp;&amp; (days &lt;= 5)) {</TD></TR><TR CLASS="c"><TD CLASS="l">135</TD><TD>                                weatherCondition = new WeatherCondition();</TD></TR><TR CLASS="c"><TD CLASS="l">136</TD><TD>                                List&lt;Weather&gt; weather = new ArrayList&lt;Weather&gt;();</TD></TR><TR><TD CLASS="l">137</TD><TD> </TD></TR><TR><TD CLASS="l">138</TD><TD>                                // Get weather</TD></TR><TR CLASS="c"><TD CLASS="l">139</TD><TD>                                WeatherResponse response = getDataWeather(name, country, days);</TD></TR><TR><TD CLASS="l">140</TD><TD> </TD></TR><TR><TD CLASS="l">141</TD><TD>                                // Map info weather in WeatherCondition object</TD></TR><TR CLASS="c"><TD CLASS="l">142</TD><TD>                                RequestData[] requestData = response.getData().getRequest();</TD></TR><TR CLASS="c"><TD CLASS="l">143</TD><TD>                                weatherCondition.setCountry(getCountry(requestData[0]));</TD></TR><TR CLASS="c"><TD CLASS="l">144</TD><TD>                                weatherCondition.setLocation(getLocation(requestData[0]));</TD></TR><TR><TD CLASS="l">145</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">146</TD><TD>                                ConditionData[] conditionData = response.getData().getCurrent_condition();</TD></TR><TR><TD CLASS="l">147</TD><TD>                                </TD></TR><TR CLASS="c"><TD CLASS="l">148</TD><TD>                                weatherCondition.setLastWeatherObservation(getCurrentCondition(conditionData[0], language));</TD></TR><TR><TD CLASS="l">149</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">150</TD><TD>                                WeatherData[] weatherData = response.getData().getWeather();</TD></TR><TR><TD CLASS="l">151</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">152</TD><TD>                                for (int i = 0; i &lt; weatherData.length; i++) {</TD></TR><TR CLASS="c"><TD CLASS="l">153</TD><TD>                                        logger.error(weatherData[i].getWeatherDesc()[0].getValue());</TD></TR><TR CLASS="c"><TD CLASS="l">154</TD><TD>                                        weather.add(getWeather(weatherData[i], language));</TD></TR><TR><TD CLASS="l">155</TD><TD>                                }</TD></TR><TR><TD CLASS="l">156</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">157</TD><TD>                                weatherCondition.setWeatherCondition(weather);</TD></TR><TR><TD CLASS="l">158</TD><TD> </TD></TR><TR><TD CLASS="l">159</TD><TD>                        } else {</TD></TR><TR CLASS="c"><TD CLASS="l">160</TD><TD>                                throw new WeatherException(&#34;Days are incorrect. Value must be between 1 to 5&#34;);</TD></TR><TR><TD CLASS="l">161</TD><TD>                        }</TD></TR><TR><TD CLASS="l">162</TD><TD> </TD></TR><TR><TD CLASS="l">163</TD><TD>                </TD></TR><TR><TD CLASS="l">164</TD><TD>                        // modification cause: set new preferences after the last weather</TD></TR><TR><TD CLASS="l">165</TD><TD>                        // prediction</TD></TR><TR CLASS="c"><TD CLASS="l">166</TD><TD>                        setPreferences(name, country, user);</TD></TR><TR><TD CLASS="l">167</TD><TD> </TD></TR><TR><TD CLASS="l">168</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">169</TD><TD>                logger.debug(&#34;Exit: getWeather()&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">170</TD><TD>                return weatherCondition;</TD></TR><TR><TD CLASS="l">171</TD><TD>        }</TD></TR><TR><TD CLASS="l"><A NAME="f">172</A></TD><TD> </TD></TR><TR><TD CLASS="l">173</TD><TD>        @Override</TD></TR><TR><TD CLASS="l">174</TD><TD>        public List&lt;WeatherPreferences&gt; getPreferences(Integer user, Language language) throws WeatherException {</TD></TR><TR><TD CLASS="l">175</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">176</TD><TD>                logger.debug(&#34;Enter: getPreferences(&#34; + language + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">177</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">178</TD><TD>                IWeatherUserModel wum = null;</TD></TR><TR CLASS="c"><TD CLASS="l">179</TD><TD>                List&lt;WeatherPreferences&gt; preferenceList = null;</TD></TR><TR><TD CLASS="l">180</TD><TD> </TD></TR><TR><TD CLASS="l">181</TD><TD>                // Instances WeatherUserModelImpl</TD></TR><TR CLASS="c"><TD CLASS="l">182</TD><TD>                wum = new WeatherUserModelImpl(user, weatherDB);</TD></TR><TR><TD CLASS="l">183</TD><TD> </TD></TR><TR><TD CLASS="l">184</TD><TD>                // Get preferences</TD></TR><TR CLASS="c"><TD CLASS="l">185</TD><TD>                preferenceList = wum.getPreferences(language);</TD></TR><TR CLASS="c"><TD CLASS="l">186</TD><TD>                logger.debug(&#34;Exit: getPreferences()&#34;);</TD></TR><TR><TD CLASS="l">187</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">188</TD><TD>                return preferenceList;</TD></TR><TR><TD CLASS="l">189</TD><TD> </TD></TR><TR><TD CLASS="l">190</TD><TD>        }</TD></TR><TR><TD CLASS="l"><A NAME="a">191</A></TD><TD> </TD></TR><TR><TD CLASS="l">192</TD><TD>        @Override</TD></TR><TR><TD CLASS="l">193</TD><TD>        public void setPreferences(String location, String country, Integer user) throws WeatherException {</TD></TR><TR><TD CLASS="l">194</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">195</TD><TD>                logger.debug(&#34;Enter: setPreferences(&#34; + location + &#34;,&#34; + country +  &#34;)&#34;);</TD></TR><TR><TD CLASS="l">196</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">197</TD><TD>                if ((location == null || location.trim().isEmpty()) || (country == null || country.trim().isEmpty())) {</TD></TR><TR CLASS="c"><TD CLASS="l">198</TD><TD>                        throw new WeatherException(&#34;Location is empty&#34;);</TD></TR><TR><TD CLASS="l">199</TD><TD>                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">200</TD><TD>                        IWeatherUserModel wum = null;</TD></TR><TR><TD CLASS="l">201</TD><TD>                        try {</TD></TR><TR CLASS="c"><TD CLASS="l">202</TD><TD>                                wum = new WeatherUserModelImpl(user, weatherDB);</TD></TR><TR CLASS="z"><TD CLASS="l">203</TD><TD>                        } catch (WeatherException e) {</TD></TR><TR CLASS="z"><TD CLASS="l">204</TD><TD>                                logger.error(e.getMessage());</TD></TR><TR><TD CLASS="l">205</TD><TD>                        }</TD></TR><TR><TD CLASS="l">206</TD><TD> </TD></TR><TR><TD CLASS="l">207</TD><TD>                        // Set preferences</TD></TR><TR CLASS="c"><TD CLASS="l">208</TD><TD>                        WeatherPreferences preferences = new WeatherPreferences(user, location, country);</TD></TR><TR CLASS="c"><TD CLASS="l">209</TD><TD>                        wum.setPreferences(preferences);</TD></TR><TR><TD CLASS="l">210</TD><TD> </TD></TR><TR><TD CLASS="l">211</TD><TD>                        // Save preferences</TD></TR><TR CLASS="c"><TD CLASS="l">212</TD><TD>                        wum.saveUserModel();</TD></TR><TR CLASS="c"><TD CLASS="l">213</TD><TD>                        logger.debug(&#34;Exit: setPreferences()&#34;);</TD></TR><TR><TD CLASS="l">214</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">215</TD><TD>                        wum = null;</TD></TR><TR><TD CLASS="l">216</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">217</TD><TD>        }</TD></TR><TR><TD CLASS="l">218</TD><TD>        </TD></TR><TR><TD CLASS="l">219</TD><TD> </TD></TR><TR><TD CLASS="l">220</TD><TD>        // ------------------------------------------ PRIVATE METHODS --------------------------------------------</TD></TR><TR><TD CLASS="l">221</TD><TD> </TD></TR><TR><TD CLASS="l">222</TD><TD>        /**</TD></TR><TR><TD CLASS="l">223</TD><TD>         * Translate String to unicode format String. </TD></TR><TR><TD CLASS="l">224</TD><TD>         * @param loc</TD></TR><TR><TD CLASS="l">225</TD><TD>         *            Location name</TD></TR><TR><TD CLASS="l"><A NAME="10">226</A></TD><TD>         * @return unicodeLocation Normalize location</TD></TR><TR><TD CLASS="l">227</TD><TD>         * @see String</TD></TR><TR><TD CLASS="l">228</TD><TD>         */</TD></TR><TR><TD CLASS="l">229</TD><TD>        private String getUnicodeLocation(String loc) {</TD></TR><TR CLASS="c"><TD CLASS="l">230</TD><TD>                logger.debug(&#34;Enter: getUnicodeLocation(&#34;+ loc + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">231</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">232</TD><TD>                String location = loc.toLowerCase();</TD></TR><TR CLASS="c"><TD CLASS="l">233</TD><TD>                location = location.replace(&#34;,&#34;, &#34; &#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">234</TD><TD>                location = location.trim();</TD></TR><TR CLASS="c"><TD CLASS="l">235</TD><TD>                byte[] bytes = location.getBytes();</TD></TR><TR CLASS="c"><TD CLASS="l">236</TD><TD>                for (int i = 0; i &lt; bytes.length; i++) {</TD></TR><TR CLASS="c"><TD CLASS="l">237</TD><TD>                        byte b = bytes[i];</TD></TR><TR CLASS="c"><TD CLASS="l">238</TD><TD>                        b = getByte(b);</TD></TR><TR CLASS="c"><TD CLASS="l">239</TD><TD>                        bytes[i] = b;</TD></TR><TR><TD CLASS="l">240</TD><TD>                }</TD></TR><TR><TD CLASS="l">241</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">242</TD><TD>                String unicodeLocation = new String(bytes);</TD></TR><TR CLASS="c"><TD CLASS="l">243</TD><TD>                unicodeLocation = getStringWithOneSpace(unicodeLocation);</TD></TR><TR CLASS="c"><TD CLASS="l">244</TD><TD>                unicodeLocation = unicodeLocation.replace(&#34; &#34;, &#34;_&#34;);</TD></TR><TR><TD CLASS="l">245</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">246</TD><TD>                logger.debug(&#34;Exit: getUnicodeLocation() -&gt; &#34; + unicodeLocation);</TD></TR><TR CLASS="c"><TD CLASS="l">247</TD><TD>                return unicodeLocation;</TD></TR><TR><TD CLASS="l">248</TD><TD>        }</TD></TR><TR><TD CLASS="l">249</TD><TD> </TD></TR><TR><TD CLASS="l">250</TD><TD>        /**</TD></TR><TR><TD CLASS="l">251</TD><TD>         * Return a String with only one space between words. </TD></TR><TR><TD CLASS="l">252</TD><TD>         * @param name</TD></TR><TR><TD CLASS="l">253</TD><TD>         *            String name</TD></TR><TR><TD CLASS="l"><A NAME="4">254</A></TD><TD>         * @return result String with only one space between words</TD></TR><TR><TD CLASS="l">255</TD><TD>         * @see String</TD></TR><TR><TD CLASS="l">256</TD><TD>         */</TD></TR><TR><TD CLASS="l">257</TD><TD>        private String getStringWithOneSpace(String name) {</TD></TR><TR CLASS="c"><TD CLASS="l">258</TD><TD>                logger.debug(&#34;Enter: getStringWithOneSpace(&#34;+ name + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">259</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">260</TD><TD>                String string = &#34; &#34;;</TD></TR><TR CLASS="c"><TD CLASS="l">261</TD><TD>                String result = null;</TD></TR><TR CLASS="c"><TD CLASS="l">262</TD><TD>                char space = string.charAt(0);</TD></TR><TR CLASS="c"><TD CLASS="l">263</TD><TD>                char[] array = name.toCharArray();</TD></TR><TR CLASS="c"><TD CLASS="l">264</TD><TD>                int count = 1;</TD></TR><TR CLASS="c"><TD CLASS="l">265</TD><TD>                int times = 0;</TD></TR><TR CLASS="c"><TD CLASS="l">266</TD><TD>                while (count &lt; array.length) {</TD></TR><TR CLASS="c"><TD CLASS="l">267</TD><TD>                        if ((count &gt; 0) &amp;&amp; (count + 1 &lt; array.length)) {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="42% line coverage (5 out of 12 instructions)">268</TD><TD TITLE="42% line coverage (5 out of 12 instructions)">                                if ((array[count] == space) &amp;&amp; (array[count + 1] == space)) {</TD></TR><TR CLASS="z"><TD CLASS="l">269</TD><TD>                                        for (int j = count; j &lt; array.length - 1; j++) {</TD></TR><TR CLASS="z"><TD CLASS="l">270</TD><TD>                                                array[j] = array[j + 1];</TD></TR><TR><TD CLASS="l">271</TD><TD> </TD></TR><TR><TD CLASS="l">272</TD><TD>                                        }</TD></TR><TR CLASS="z"><TD CLASS="l">273</TD><TD>                                        times = times + 1;</TD></TR><TR><TD CLASS="l">274</TD><TD>                                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">275</TD><TD>                                        count = count + 1;</TD></TR><TR><TD CLASS="l">276</TD><TD>                                }</TD></TR><TR><TD CLASS="l">277</TD><TD>                        } else {</TD></TR><TR CLASS="c"><TD CLASS="l">278</TD><TD>                                count = count + 1;</TD></TR><TR><TD CLASS="l">279</TD><TD>                        }</TD></TR><TR><TD CLASS="l">280</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">281</TD><TD>                char[] newArray = new char[array.length - times];</TD></TR><TR CLASS="c"><TD CLASS="l">282</TD><TD>                for (int j = 0; j &lt; array.length - times; j++) {</TD></TR><TR CLASS="c"><TD CLASS="l">283</TD><TD>                        newArray[j] = array[j];</TD></TR><TR><TD CLASS="l">284</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">285</TD><TD>                result = new String(newArray);</TD></TR><TR><TD CLASS="l">286</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">287</TD><TD>                logger.debug(&#34;Exit: getStringWithOneSpace() -&gt; &#34; + result);</TD></TR><TR CLASS="c"><TD CLASS="l">288</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">289</TD><TD>        }</TD></TR><TR><TD CLASS="l">290</TD><TD> </TD></TR><TR><TD CLASS="l">291</TD><TD>        /**</TD></TR><TR><TD CLASS="l">292</TD><TD>         * Translate String to unicode format String. </TD></TR><TR><TD CLASS="l">293</TD><TD>         * @param byte byte to map</TD></TR><TR><TD CLASS="l"><A NAME="2">294</A></TD><TD>         * @return byte byte unicode</TD></TR><TR><TD CLASS="l">295</TD><TD>         * @see byte</TD></TR><TR><TD CLASS="l">296</TD><TD>         */</TD></TR><TR><TD CLASS="l">297</TD><TD>        private byte getByte(byte b) {</TD></TR><TR CLASS="c"><TD CLASS="l">298</TD><TD>                logger.debug(&#34;Enter: getByte(&#34; + b + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">299</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">300</TD><TD>                byte result = 0;</TD></TR><TR CLASS="c"><TD CLASS="l">301</TD><TD>                switch (b) {</TD></TR><TR><TD CLASS="l">302</TD><TD>                case -31:</TD></TR><TR><TD CLASS="l">303</TD><TD>                case -32:</TD></TR><TR><TD CLASS="l">304</TD><TD>                case -28:</TD></TR><TR CLASS="z"><TD CLASS="l">305</TD><TD>                        result = 97;</TD></TR><TR CLASS="z"><TD CLASS="l">306</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">307</TD><TD>                case -23:</TD></TR><TR><TD CLASS="l">308</TD><TD>                case -24:</TD></TR><TR><TD CLASS="l">309</TD><TD>                case -21:</TD></TR><TR CLASS="z"><TD CLASS="l">310</TD><TD>                        result = 101;</TD></TR><TR CLASS="z"><TD CLASS="l">311</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">312</TD><TD>                case -19:</TD></TR><TR><TD CLASS="l">313</TD><TD>                case -20:</TD></TR><TR><TD CLASS="l">314</TD><TD>                case -17:</TD></TR><TR CLASS="z"><TD CLASS="l">315</TD><TD>                        result = 105;</TD></TR><TR CLASS="z"><TD CLASS="l">316</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">317</TD><TD>                case -13:</TD></TR><TR><TD CLASS="l">318</TD><TD>                case -14:</TD></TR><TR><TD CLASS="l">319</TD><TD>                case -10:</TD></TR><TR CLASS="z"><TD CLASS="l">320</TD><TD>                        result = 111;</TD></TR><TR CLASS="z"><TD CLASS="l">321</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">322</TD><TD>                case -6:</TD></TR><TR><TD CLASS="l">323</TD><TD>                case -7:</TD></TR><TR><TD CLASS="l">324</TD><TD>                case -4:</TD></TR><TR CLASS="z"><TD CLASS="l">325</TD><TD>                        result = 117;</TD></TR><TR CLASS="z"><TD CLASS="l">326</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">327</TD><TD>                case -15:</TD></TR><TR CLASS="z"><TD CLASS="l">328</TD><TD>                        result = 110;</TD></TR><TR CLASS="z"><TD CLASS="l">329</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">330</TD><TD>                case -25:</TD></TR><TR CLASS="z"><TD CLASS="l">331</TD><TD>                        result = 99;</TD></TR><TR CLASS="z"><TD CLASS="l">332</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">333</TD><TD>                default:</TD></TR><TR CLASS="c"><TD CLASS="l">334</TD><TD>                        result = b;</TD></TR><TR><TD CLASS="l">335</TD><TD>                        break;</TD></TR><TR><TD CLASS="l">336</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">337</TD><TD>                logger.debug(&#34;Exit: getByte() -&gt; &#34; + result);</TD></TR><TR CLASS="c"><TD CLASS="l">338</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">339</TD><TD>        }</TD></TR><TR><TD CLASS="l">340</TD><TD> </TD></TR><TR><TD CLASS="l">341</TD><TD>        /**</TD></TR><TR><TD CLASS="l">342</TD><TD>         * Get locations from Free Weather API. </TD></TR><TR><TD CLASS="l">343</TD><TD>         * @param location</TD></TR><TR><TD CLASS="l">344</TD><TD>         *            Name to search</TD></TR><TR><TD CLASS="l">345</TD><TD>         * @return LocationResponse LocationResponse object with locations</TD></TR><TR><TD CLASS="l">346</TD><TD>         * @throws WeatherException</TD></TR><TR><TD CLASS="l">347</TD><TD>         *             If an exception occurred</TD></TR><TR><TD CLASS="l">348</TD><TD>         * @see HttpURLConnection, InputStreamReader, StringBuffer, ObjectMapper,</TD></TR><TR><TD CLASS="l"><A NAME="6">349</A></TD><TD>         *      LocationResponse</TD></TR><TR><TD CLASS="l">350</TD><TD>         */</TD></TR><TR><TD CLASS="l">351</TD><TD>        private LocationResponse getDataLocation(String location)</TD></TR><TR><TD CLASS="l">352</TD><TD>                        throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">353</TD><TD>                logger.debug(&#34;Enter: getDataLocation(&#34; + location + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">354</TD><TD> </TD></TR><TR><TD CLASS="l">355</TD><TD>                URL url;</TD></TR><TR CLASS="c"><TD CLASS="l">356</TD><TD>                LocationResponse locationResponse = null;</TD></TR><TR><TD CLASS="l">357</TD><TD>                try {</TD></TR><TR CLASS="c"><TD CLASS="l">358</TD><TD>                        url = new URL(&#34;http://&#34;+domain+&#34;/feed/search.ashx?key=&#34; + key + &#34;&amp;query=&#34; + location + &#34;&amp;format=json&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">359</TD><TD>                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();</TD></TR><TR CLASS="c"><TD CLASS="l">360</TD><TD>                        conn.connect();</TD></TR><TR CLASS="c"><TD CLASS="l">361</TD><TD>                        InputStreamReader in = new InputStreamReader(</TD></TR><TR CLASS="c"><TD CLASS="l">362</TD><TD>                                        (InputStream) conn.getContent());</TD></TR><TR CLASS="c"><TD CLASS="l">363</TD><TD>                        BufferedReader buff = new BufferedReader(in);</TD></TR><TR CLASS="c"><TD CLASS="l">364</TD><TD>                        StringBuffer text = new StringBuffer();</TD></TR><TR><TD CLASS="l">365</TD><TD>                        // Read lines from response and pass to a String</TD></TR><TR><TD CLASS="l">366</TD><TD>                        do {</TD></TR><TR CLASS="c"><TD CLASS="l">367</TD><TD>                                text.append(buff.readLine() + &#34;\n&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">368</TD><TD>                        } while (buff.readLine() != null);</TD></TR><TR CLASS="c"><TD CLASS="l">369</TD><TD>                        String json = text.toString();</TD></TR><TR CLASS="c"><TD CLASS="l">370</TD><TD>                        ObjectMapper mapper = new ObjectMapper();</TD></TR><TR><TD CLASS="l">371</TD><TD>                        // Map json string into LocationResponse object</TD></TR><TR CLASS="c"><TD CLASS="l">372</TD><TD>                        locationResponse = mapper.readValue(json, LocationResponse.class);</TD></TR><TR CLASS="c"><TD CLASS="l">373</TD><TD>                        if (locationResponse.getSearch_api() == null) {</TD></TR><TR CLASS="c"><TD CLASS="l">374</TD><TD>                                logger.error(&#34;Location doesnÂ´t exist&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">375</TD><TD>                                throw new WeatherException(&#34;Location doesnÂ´t exist&#34;);</TD></TR><TR><TD CLASS="l">376</TD><TD>                        }</TD></TR><TR CLASS="z"><TD CLASS="l">377</TD><TD>                } catch (IOException e) {</TD></TR><TR CLASS="z"><TD CLASS="l">378</TD><TD>                        logger.error(e.getMessage(),e);</TD></TR><TR CLASS="z"><TD CLASS="l">379</TD><TD>                        throw new WeatherException(e.getMessage(), e.getCause());</TD></TR><TR><TD CLASS="l">380</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">381</TD><TD>                logger.debug(&#34;Exit: getDataLocation() -&gt; &#34; + locationResponse);</TD></TR><TR><TD CLASS="l">382</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">383</TD><TD>                return locationResponse;</TD></TR><TR><TD CLASS="l">384</TD><TD>        }</TD></TR><TR><TD CLASS="l">385</TD><TD> </TD></TR><TR><TD CLASS="l">386</TD><TD>        /**</TD></TR><TR><TD CLASS="l">387</TD><TD>         * Get weather from Free Weather API. </TD></TR><TR><TD CLASS="l">388</TD><TD>         * @param name</TD></TR><TR><TD CLASS="l">389</TD><TD>         *            City or Town name</TD></TR><TR><TD CLASS="l">390</TD><TD>         * @param country</TD></TR><TR><TD CLASS="l">391</TD><TD>         *            Country name</TD></TR><TR><TD CLASS="l">392</TD><TD>         * @param days</TD></TR><TR><TD CLASS="l">393</TD><TD>         *            Number of days for prediction</TD></TR><TR><TD CLASS="l">394</TD><TD>         * @return WeatherResponse Object with weather information</TD></TR><TR><TD CLASS="l">395</TD><TD>         * @throws WeatherException</TD></TR><TR><TD CLASS="l">396</TD><TD>         *             If an exception occurred</TD></TR><TR><TD CLASS="l">397</TD><TD>         * @see HttpURLConnection, InputStreamReader, StringBuffer, ObjectMapper,</TD></TR><TR><TD CLASS="l"><A NAME="b">398</A></TD><TD>         *      WeatherResponse</TD></TR><TR><TD CLASS="l">399</TD><TD>         */</TD></TR><TR><TD CLASS="l">400</TD><TD>        private WeatherResponse getDataWeather(String name, String country, int days)</TD></TR><TR><TD CLASS="l">401</TD><TD>                        throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">402</TD><TD>                URL url = null;</TD></TR><TR CLASS="c"><TD CLASS="l">403</TD><TD>                WeatherResponse weatherResponse = null;</TD></TR><TR><TD CLASS="l">404</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">405</TD><TD>                logger.debug(&#34;Enter: getDataWeather (&#34; + name + &#34;,&#34; + country + &#34;,&#34; + days + &#34;)&#34;);</TD></TR><TR><TD CLASS="l">406</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">407</TD><TD>                name = name.trim();</TD></TR><TR CLASS="c"><TD CLASS="l">408</TD><TD>                country = country.trim();</TD></TR><TR CLASS="c"><TD CLASS="l">409</TD><TD>                name = getStringWithOneSpace(name);</TD></TR><TR CLASS="c"><TD CLASS="l">410</TD><TD>                country = getStringWithOneSpace(country);</TD></TR><TR CLASS="c"><TD CLASS="l">411</TD><TD>                name = name.replace(&#34;, &#34;, &#34;,&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">412</TD><TD>                country = country.replace(&#34;, &#34;, &#34;,&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">413</TD><TD>                name = name.replace(&#34; &#34;, &#34;_&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">414</TD><TD>                country = country.replace(&#34; &#34;, &#34;_&#34;);</TD></TR><TR><TD CLASS="l">415</TD><TD>                try {</TD></TR><TR CLASS="c"><TD CLASS="l">416</TD><TD>                        url = new URL(</TD></TR><TR CLASS="c"><TD CLASS="l">417</TD><TD>                                        &#34;http://&#34;+domain+&#34;/feed/weather.ashx?q=&#34;</TD></TR><TR CLASS="c"><TD CLASS="l">418</TD><TD>                                                        + name + &#34;,&#34; + country</TD></TR><TR CLASS="c"><TD CLASS="l">419</TD><TD>                                                        + &#34;&amp;format=json&amp;num_of_days=&#34; + days + &#34;&amp;key=&#34;</TD></TR><TR CLASS="c"><TD CLASS="l">420</TD><TD>                                                        + key);</TD></TR><TR CLASS="c"><TD CLASS="l">421</TD><TD>                        HttpURLConnection conn = (HttpURLConnection) url.openConnection();</TD></TR><TR CLASS="c"><TD CLASS="l">422</TD><TD>                        conn.connect();</TD></TR><TR CLASS="c"><TD CLASS="l">423</TD><TD>                        InputStreamReader in = new InputStreamReader(</TD></TR><TR CLASS="c"><TD CLASS="l">424</TD><TD>                                        (InputStream) conn.getContent());</TD></TR><TR CLASS="c"><TD CLASS="l">425</TD><TD>                        BufferedReader buff = new BufferedReader(in);</TD></TR><TR CLASS="c"><TD CLASS="l">426</TD><TD>                        StringBuffer text = new StringBuffer();</TD></TR><TR><TD CLASS="l">427</TD><TD>                        // Read lines from response and pass to a String</TD></TR><TR><TD CLASS="l">428</TD><TD>                        do {</TD></TR><TR CLASS="c"><TD CLASS="l">429</TD><TD>                                text.append(buff.readLine() + &#34;\n&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">430</TD><TD>                        } while (buff.readLine() != null);</TD></TR><TR CLASS="c"><TD CLASS="l">431</TD><TD>                        String json = text.toString();</TD></TR><TR CLASS="c"><TD CLASS="l">432</TD><TD>                        ObjectMapper mapper = new ObjectMapper();</TD></TR><TR><TD CLASS="l">433</TD><TD> </TD></TR><TR><TD CLASS="l">434</TD><TD>                        // Map json string into WeatherResponse object</TD></TR><TR CLASS="c"><TD CLASS="l">435</TD><TD>                        weatherResponse = mapper.readValue(json, WeatherResponse.class);</TD></TR><TR CLASS="z"><TD CLASS="l">436</TD><TD>                } catch (IOException e) {</TD></TR><TR CLASS="z"><TD CLASS="l">437</TD><TD>                        logger.error(e.getMessage(),e);</TD></TR><TR CLASS="z"><TD CLASS="l">438</TD><TD>                        throw new WeatherException(&#34;Location and/or country are wrong&#34;);</TD></TR><TR><TD CLASS="l">439</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">440</TD><TD>                logger.debug(&#34;Exit: getDataWeather()&#34;);</TD></TR><TR><TD CLASS="l">441</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">442</TD><TD>                return weatherResponse;</TD></TR><TR><TD CLASS="l">443</TD><TD>        }</TD></TR><TR><TD CLASS="l">444</TD><TD> </TD></TR><TR><TD CLASS="l">445</TD><TD>        /**</TD></TR><TR><TD CLASS="l">446</TD><TD>         * Get icon object (description about icon) by description code and current</TD></TR><TR><TD CLASS="l">447</TD><TD>         * time prediction. </TD></TR><TR><TD CLASS="l">448</TD><TD>         * @param description</TD></TR><TR><TD CLASS="l">449</TD><TD>         *            Description code get as response</TD></TR><TR><TD CLASS="l">450</TD><TD>         * @return Description Description object</TD></TR><TR><TD CLASS="l">451</TD><TD>         * @throws WeatherException</TD></TR><TR><TD CLASS="l">452</TD><TD>         *             If an exception occurred</TD></TR><TR><TD CLASS="l">453</TD><TD>         * @see Description, Calendar</TD></TR><TR><TD CLASS="l">454</TD><TD>         */</TD></TR><TR><TD CLASS="l">455</TD><TD> </TD></TR><TR><TD CLASS="l"><A NAME="3">456</A></TD><TD>        // modification cause: some of the descriptions were assigned to incorrect</TD></TR><TR><TD CLASS="l">457</TD><TD>        // icons</TD></TR><TR><TD CLASS="l">458</TD><TD>        // must be added an icon for 'Blizzard'. Now is related with 'cloudy'</TD></TR><TR><TD CLASS="l">459</TD><TD>        private String getIcon(String description) throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">460</TD><TD>                logger.debug(&#34;Enter: getDescription (String description)&#34; + description.toLowerCase());</TD></TR><TR CLASS="c"><TD CLASS="l">461</TD><TD>                String icon = null;</TD></TR><TR><TD CLASS="l">462</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">463</TD><TD>                if (description.toLowerCase().contains(&#34;rain&#34;) || (description.toLowerCase().contains(&#34;drizzle&#34;))) {</TD></TR><TR CLASS="z"><TD CLASS="l">464</TD><TD>                        icon = &#34;rain&#34;;</TD></TR><TR CLASS="c"><TD CLASS="l">465</TD><TD>                } else if (description.toLowerCase().contains(&#34;snow&#34;)</TD></TR><TR CLASS="c"><TD CLASS="l">466</TD><TD>                                || (description.toLowerCase().contains(&#34;sleet&#34;) || (description.toLowerCase().contains(&#34;pellets&#34;)))) {</TD></TR><TR CLASS="z"><TD CLASS="l">467</TD><TD>                        icon = &#34;snow&#34;;</TD></TR><TR CLASS="c"><TD CLASS="l">468</TD><TD>                } else if (description.toLowerCase().contains(&#34;cloud&#34;)) {</TD></TR><TR CLASS="z"><TD CLASS="l">469</TD><TD>                        icon = &#34;cloudy&#34;;</TD></TR><TR CLASS="c"><TD CLASS="l">470</TD><TD>                } else if (description.toLowerCase().contains(&#34;storm&#34;)</TD></TR><TR CLASS="c"><TD CLASS="l">471</TD><TD>                                || (description.toLowerCase().contains(&#34;thundery&#34;))) {</TD></TR><TR CLASS="z"><TD CLASS="l">472</TD><TD>                        icon = &#34;storm&#34;;</TD></TR><TR CLASS="c"><TD CLASS="l">473</TD><TD>                } else if (description.toLowerCase().contains(&#34;sunny&#34;)</TD></TR><TR CLASS="z"><TD CLASS="l">474</TD><TD>                                || (description.toLowerCase().contains(&#34;clear&#34;))) {</TD></TR><TR CLASS="c"><TD CLASS="l">475</TD><TD>                        icon = &#34;sunny&#34;;</TD></TR><TR CLASS="z"><TD CLASS="l">476</TD><TD>                } else if ((description.toLowerCase().contains(&#34;mist&#34;))</TD></TR><TR CLASS="z"><TD CLASS="l">477</TD><TD>                                || (description.toLowerCase().contains(&#34;fog&#34;))</TD></TR><TR CLASS="z"><TD CLASS="l">478</TD><TD>                                || (description.toLowerCase().contains(&#34;over&#34;))) {</TD></TR><TR CLASS="z"><TD CLASS="l">479</TD><TD>                        icon = &#34;cloudy&#34;;</TD></TR><TR><TD CLASS="l">480</TD><TD>                } else {</TD></TR><TR CLASS="z"><TD CLASS="l">481</TD><TD>                        icon = &#34;cloudy&#34;;</TD></TR><TR><TD CLASS="l">482</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">483</TD><TD>                logger.debug(&#34;Exit: getDescription (String description)&#34;);</TD></TR><TR><TD CLASS="l">484</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">485</TD><TD>                return icon;</TD></TR><TR><TD CLASS="l">486</TD><TD>        }</TD></TR><TR><TD CLASS="l">487</TD><TD> </TD></TR><TR><TD CLASS="l">488</TD><TD>        /**</TD></TR><TR><TD CLASS="l">489</TD><TD>         * Get country from RequestData. </TD></TR><TR><TD CLASS="l">490</TD><TD>         * @param request</TD></TR><TR><TD CLASS="l">491</TD><TD>         *            RequestData to get information</TD></TR><TR><TD CLASS="l"><A NAME="8">492</A></TD><TD>         * @return country Country name</TD></TR><TR><TD CLASS="l">493</TD><TD>         * @see String</TD></TR><TR><TD CLASS="l">494</TD><TD>         */</TD></TR><TR><TD CLASS="l">495</TD><TD>        private String getCountry(RequestData request) {</TD></TR><TR CLASS="c"><TD CLASS="l">496</TD><TD>                logger.debug(&#34;Enter: getCountry (RequestData request)&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">497</TD><TD>                if (request != null) {</TD></TR><TR><TD CLASS="l">498</TD><TD>                        // Separate Name and Country locatio from the same String</TD></TR><TR CLASS="c"><TD CLASS="l">499</TD><TD>                        String query = request.getQuery();</TD></TR><TR CLASS="c"><TD CLASS="l">500</TD><TD>                        String[] names = query.split(&#34;,&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">501</TD><TD>                        logger.debug(&#34;Exit: getCountry (RequestData request)&#34;);</TD></TR><TR><TD CLASS="l">502</TD><TD> </TD></TR><TR><TD CLASS="l">503</TD><TD>                        // Return Country name location</TD></TR><TR CLASS="c"><TD CLASS="l">504</TD><TD>                        return names[1];</TD></TR><TR><TD CLASS="l">505</TD><TD>                } else {</TD></TR><TR CLASS="z"><TD CLASS="l">506</TD><TD>                        return null;</TD></TR><TR><TD CLASS="l">507</TD><TD>                }</TD></TR><TR><TD CLASS="l">508</TD><TD>        }</TD></TR><TR><TD CLASS="l">509</TD><TD> </TD></TR><TR><TD CLASS="l">510</TD><TD>        /**</TD></TR><TR><TD CLASS="l">511</TD><TD>         * Get location name from RequestData. </TD></TR><TR><TD CLASS="l">512</TD><TD>         * @param request</TD></TR><TR><TD CLASS="l">513</TD><TD>         *            RequestData object to get information</TD></TR><TR><TD CLASS="l"><A NAME="9">514</A></TD><TD>         * @return location Location name</TD></TR><TR><TD CLASS="l">515</TD><TD>         * @see String</TD></TR><TR><TD CLASS="l">516</TD><TD>         */</TD></TR><TR><TD CLASS="l">517</TD><TD>        private String getLocation(RequestData request) {</TD></TR><TR CLASS="c"><TD CLASS="l">518</TD><TD>                logger.debug(&#34;Enter: getLocation (RequestData request)&#34;);</TD></TR><TR><TD CLASS="l">519</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">520</TD><TD>                if (request != null) {</TD></TR><TR><TD CLASS="l">521</TD><TD>                        // Separate Name and Country location from the same String</TD></TR><TR CLASS="c"><TD CLASS="l">522</TD><TD>                        String query = request.getQuery();</TD></TR><TR CLASS="c"><TD CLASS="l">523</TD><TD>                        String[] names = query.split(&#34;,&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">524</TD><TD>                        logger.debug(&#34;Exit: getLocation (RequestData request)&#34;);</TD></TR><TR><TD CLASS="l">525</TD><TD> </TD></TR><TR><TD CLASS="l">526</TD><TD>                        // Return name location</TD></TR><TR CLASS="c"><TD CLASS="l">527</TD><TD>                        return names[0];</TD></TR><TR><TD CLASS="l">528</TD><TD>                } else {</TD></TR><TR CLASS="z"><TD CLASS="l">529</TD><TD>                        return null;</TD></TR><TR><TD CLASS="l">530</TD><TD>                }</TD></TR><TR><TD CLASS="l">531</TD><TD>        }</TD></TR><TR><TD CLASS="l">532</TD><TD> </TD></TR><TR><TD CLASS="l">533</TD><TD>        /**</TD></TR><TR><TD CLASS="l">534</TD><TD>         * Get CurrentCondition weather from ConditionData object. </TD></TR><TR><TD CLASS="l">535</TD><TD>         * @param condition</TD></TR><TR><TD CLASS="l">536</TD><TD>         *            ConditionData object to get information</TD></TR><TR><TD CLASS="l">537</TD><TD>         * @param language</TD></TR><TR><TD CLASS="l">538</TD><TD>         *            language to get the current condition</TD></TR><TR><TD CLASS="l">539</TD><TD>         * @return Weather CurrentCondition weather with information</TD></TR><TR><TD CLASS="l">540</TD><TD>         * @throws WeatherException</TD></TR><TR><TD CLASS="l">541</TD><TD>         *             If exception occurred</TD></TR><TR><TD CLASS="l">542</TD><TD>         * @see Temperature, Wind, Calendar, Description, Weather, Value</TD></TR><TR><TD CLASS="l">543</TD><TD>         */</TD></TR><TR><TD CLASS="l"><A NAME="5">544</A></TD><TD>        </TD></TR><TR><TD CLASS="l">545</TD><TD>        // modification cause: set the parameter 'language' for getting the</TD></TR><TR><TD CLASS="l">546</TD><TD>        // prediction in the language desired</TD></TR><TR><TD CLASS="l">547</TD><TD>        private Weather getCurrentCondition(ConditionData condition, Language language) throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">548</TD><TD>                logger.debug(&#34;Enter: getCurrentCondition(ConditionData condition)&#34;);</TD></TR><TR><TD CLASS="l">549</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">550</TD><TD>                Weather lastWeatherObservation = null;</TD></TR><TR><TD CLASS="l">551</TD><TD>                try {</TD></TR><TR CLASS="c"><TD CLASS="l">552</TD><TD>                        if (condition != null) {</TD></TR><TR CLASS="c"><TD CLASS="l">553</TD><TD>                                Calendar timeCondition = GregorianCalendar.getInstance();</TD></TR><TR CLASS="c"><TD CLASS="l">554</TD><TD>                                SimpleDateFormat s = new SimpleDateFormat(&#34;HH:mm aa&#34;);                                </TD></TR><TR CLASS="c"><TD CLASS="l">555</TD><TD>                                Date d = s.parse(condition.getObservation_time());</TD></TR><TR><TD CLASS="l">556</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">557</TD><TD>                                Calendar calendar = Calendar.getInstance();</TD></TR><TR CLASS="c"><TD CLASS="l">558</TD><TD>                                calendar.setTime(d);</TD></TR><TR CLASS="c"><TD CLASS="l">559</TD><TD>                                timeCondition.set(Calendar.HOUR, calendar.get(Calendar.HOUR));</TD></TR><TR CLASS="c"><TD CLASS="l">560</TD><TD>                                timeCondition.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE));</TD></TR><TR><TD CLASS="l">561</TD><TD>                                </TD></TR><TR CLASS="c"><TD CLASS="l">562</TD><TD>                                if (condition.getObservation_time().contains(&#34;AM&#34;)) {</TD></TR><TR CLASS="z"><TD CLASS="l">563</TD><TD>                                        timeCondition.set(Calendar.AM_PM, 0);</TD></TR><TR><TD CLASS="l">564</TD><TD>                                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">565</TD><TD>                                        timeCondition.set(Calendar.AM_PM, 1);</TD></TR><TR><TD CLASS="l">566</TD><TD>                                }</TD></TR><TR><TD CLASS="l">567</TD><TD> </TD></TR><TR><TD CLASS="l">568</TD><TD>                                // Create Temperature object</TD></TR><TR CLASS="c"><TD CLASS="l">569</TD><TD>                                Temperature temperature = new Temperature(</TD></TR><TR CLASS="c"><TD CLASS="l">570</TD><TD>                                                condition.getTemp_C(), condition.getTemp_C(),</TD></TR><TR CLASS="c"><TD CLASS="l">571</TD><TD>                                                condition.getTemp_F(), condition.getTemp_F());</TD></TR><TR><TD CLASS="l">572</TD><TD> </TD></TR><TR><TD CLASS="l">573</TD><TD>                                // Create Wind object</TD></TR><TR><TD CLASS="l">574</TD><TD>                                </TD></TR><TR><TD CLASS="l">575</TD><TD>                                // modification cause: gets the wind direction from the</TD></TR><TR><TD CLASS="l">576</TD><TD>                                // weather_config.xml using the windDirection code</TD></TR><TR CLASS="c"><TD CLASS="l">577</TD><TD>                                String windDirectionValue = xmlManager.getValueFromXmlDocument(</TD></TR><TR CLASS="c"><TD CLASS="l">578</TD><TD>                                                &#34;winddirections&#34;, condition.getWinddir16Point(), language.getReadableValue());</TD></TR><TR><TD CLASS="l">579</TD><TD>                                </TD></TR><TR CLASS="c"><TD CLASS="l">580</TD><TD>                                logger.debug(&#34;wind direction from xml: &#34; + windDirectionValue);</TD></TR><TR CLASS="c"><TD CLASS="l">581</TD><TD>                                Wind wind = new Wind(condition.getWindspeedMiles(), condition.getWindspeedKmph(), windDirectionValue);</TD></TR><TR><TD CLASS="l">582</TD><TD> </TD></TR><TR><TD CLASS="l">583</TD><TD>                                // Create description object</TD></TR><TR><TD CLASS="l">584</TD><TD>                                </TD></TR><TR><TD CLASS="l">585</TD><TD>                                // modification cause: gets the description from the</TD></TR><TR><TD CLASS="l">586</TD><TD>                                // weather_config.xml using the description code</TD></TR><TR CLASS="c"><TD CLASS="l">587</TD><TD>                                String descriptionValue = xmlManager.getValueFromXmlDocument(</TD></TR><TR CLASS="c"><TD CLASS="l">588</TD><TD>                                                &#34;weatherdescriptions&#34;,</TD></TR><TR CLASS="c"><TD CLASS="l">589</TD><TD>                                                Integer.toString(condition.getWeatherCode()),</TD></TR><TR CLASS="c"><TD CLASS="l">590</TD><TD>                                                language.getReadableValue());</TD></TR><TR><TD CLASS="l">591</TD><TD>                                // condition.getWeatherCode()</TD></TR><TR CLASS="c"><TD CLASS="l">592</TD><TD>                                logger.debug(&#34;weather description from xml: &#34; + descriptionValue);</TD></TR><TR CLASS="c"><TD CLASS="l">593</TD><TD>                                Value[] description = condition.getWeatherDesc();</TD></TR><TR><TD CLASS="l">594</TD><TD> </TD></TR><TR><TD CLASS="l">595</TD><TD>                                // Get icon URL</TD></TR><TR CLASS="c"><TD CLASS="l">596</TD><TD>                                condition.getWeatherIconUrl();</TD></TR><TR><TD CLASS="l">597</TD><TD> </TD></TR><TR><TD CLASS="l">598</TD><TD>                                // Create Weather object with last current condition</TD></TR><TR CLASS="c"><TD CLASS="l">599</TD><TD>                                lastWeatherObservation = new Weather();</TD></TR><TR CLASS="c"><TD CLASS="l">600</TD><TD>                                lastWeatherObservation.setDate(timeCondition.getTime().toString());</TD></TR><TR><TD CLASS="l">601</TD><TD> </TD></TR><TR><TD CLASS="l">602</TD><TD>                                // lastWeatherObservation.setDescription(description[0].getValue());</TD></TR><TR><TD CLASS="l">603</TD><TD>                                </TD></TR><TR><TD CLASS="l">604</TD><TD>                                // modification cause: set the description value from the xml file</TD></TR><TR CLASS="c"><TD CLASS="l">605</TD><TD>                                lastWeatherObservation.setDescription(descriptionValue);</TD></TR><TR><TD CLASS="l">606</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">607</TD><TD>                                lastWeatherObservation.setIconURL(getIcon(description[0].getValue()));</TD></TR><TR CLASS="c"><TD CLASS="l">608</TD><TD>                                lastWeatherObservation.setPrecipitation(condition.getPrecipMM());</TD></TR><TR CLASS="c"><TD CLASS="l">609</TD><TD>                                lastWeatherObservation.setTemperature(temperature);</TD></TR><TR CLASS="c"><TD CLASS="l">610</TD><TD>                                lastWeatherObservation.setWind(wind);</TD></TR><TR><TD CLASS="l">611</TD><TD>                        }</TD></TR><TR CLASS="z"><TD CLASS="l">612</TD><TD>                } catch (ParseException e) {</TD></TR><TR CLASS="z"><TD CLASS="l">613</TD><TD>                        logger.error(e.getMessage());</TD></TR><TR CLASS="z"><TD CLASS="l">614</TD><TD>                } catch (WeatherException e) {</TD></TR><TR CLASS="z"><TD CLASS="l">615</TD><TD>                        logger.error(e.getMessage());</TD></TR><TR CLASS="z"><TD CLASS="l">616</TD><TD>                        throw new WeatherException(e.getMessage(), e.getCause());</TD></TR><TR><TD CLASS="l">617</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">618</TD><TD>                logger.debug(&#34;Exit: getCurrentCondition(ConditionData condition)&#34;);</TD></TR><TR><TD CLASS="l">619</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">620</TD><TD>                return lastWeatherObservation;</TD></TR><TR><TD CLASS="l">621</TD><TD>        }</TD></TR><TR><TD CLASS="l">622</TD><TD> </TD></TR><TR><TD CLASS="l">623</TD><TD>        /**</TD></TR><TR><TD CLASS="l">624</TD><TD>         * Get Weather from WeatherData object.</TD></TR><TR><TD CLASS="l">625</TD><TD>         * @param WeatherData</TD></TR><TR><TD CLASS="l">626</TD><TD>         *            Weather object to get information</TD></TR><TR><TD CLASS="l">627</TD><TD>         * @param language</TD></TR><TR><TD CLASS="l">628</TD><TD>         *            language to get the current condition</TD></TR><TR><TD CLASS="l">629</TD><TD>         * @return weatherData WeatherData object with information</TD></TR><TR><TD CLASS="l">630</TD><TD>         * @throws WeatherException</TD></TR><TR><TD CLASS="l">631</TD><TD>         *             If exception occurred</TD></TR><TR><TD CLASS="l">632</TD><TD>         * @see Temperature, Wind, Calendar, Description, Weather, Value</TD></TR><TR><TD CLASS="l">633</TD><TD>         */</TD></TR><TR><TD CLASS="l">634</TD><TD> </TD></TR><TR><TD CLASS="l"><A NAME="7">635</A></TD><TD>        // modification cause: set the parameter 'language' for getting the</TD></TR><TR><TD CLASS="l">636</TD><TD>        // prediction in the language desired</TD></TR><TR><TD CLASS="l">637</TD><TD>        private Weather getWeather(WeatherData weatherData, Language language)</TD></TR><TR><TD CLASS="l">638</TD><TD>                        throws WeatherException {</TD></TR><TR CLASS="c"><TD CLASS="l">639</TD><TD>                logger.debug(&#34;Enter: getWeather(WeatherData weatherData)&#34;);</TD></TR><TR><TD CLASS="l">640</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">641</TD><TD>                Weather weather = null;</TD></TR><TR><TD CLASS="l">642</TD><TD>                try {</TD></TR><TR CLASS="c"><TD CLASS="l">643</TD><TD>                        if (weatherData != null) {</TD></TR><TR><TD CLASS="l">644</TD><TD> </TD></TR><TR><TD CLASS="l">645</TD><TD>                                // Create Tempetature object</TD></TR><TR CLASS="c"><TD CLASS="l">646</TD><TD>                                Temperature temperature = new Temperature(</TD></TR><TR CLASS="c"><TD CLASS="l">647</TD><TD>                                                weatherData.getTempMaxC(), weatherData.getTempMinC(),</TD></TR><TR CLASS="c"><TD CLASS="l">648</TD><TD>                                                weatherData.getTempMaxF(), weatherData.getTempMinF());</TD></TR><TR><TD CLASS="l">649</TD><TD> </TD></TR><TR><TD CLASS="l">650</TD><TD>                                // Create Wind object</TD></TR><TR><TD CLASS="l">651</TD><TD>                                </TD></TR><TR><TD CLASS="l">652</TD><TD>                                // modification cause: gets the wind direction from the</TD></TR><TR><TD CLASS="l">653</TD><TD>                                // weather_config.xml using the windDirection code</TD></TR><TR CLASS="c"><TD CLASS="l">654</TD><TD>                                String windDirectionValue = xmlManager.getValueFromXmlDocument(</TD></TR><TR CLASS="c"><TD CLASS="l">655</TD><TD>                                                &#34;winddirections&#34;, weatherData.getWinddirection(),</TD></TR><TR CLASS="c"><TD CLASS="l">656</TD><TD>                                                language.getReadableValue());</TD></TR><TR CLASS="c"><TD CLASS="l">657</TD><TD>                                logger.debug(&#34;wind direction value from xml: &#34;</TD></TR><TR CLASS="c"><TD CLASS="l">658</TD><TD>                                                + windDirectionValue);</TD></TR><TR CLASS="c"><TD CLASS="l">659</TD><TD>                                Wind wind = new Wind(weatherData.getWindspeedMiles(),</TD></TR><TR CLASS="c"><TD CLASS="l">660</TD><TD>                                                weatherData.getWindspeedKmph(), windDirectionValue);</TD></TR><TR><TD CLASS="l">661</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">662</TD><TD>                                SimpleDateFormat dateformat = new SimpleDateFormat(&#34;yyyy-MM-dd&#34;);</TD></TR><TR><TD CLASS="l">663</TD><TD>                                Date date;</TD></TR><TR><TD CLASS="l">664</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">665</TD><TD>                                date = dateformat.parse(weatherData.getDate());</TD></TR><TR CLASS="c"><TD CLASS="l">666</TD><TD>                                Calendar calendar = Calendar.getInstance();</TD></TR><TR CLASS="c"><TD CLASS="l">667</TD><TD>                                calendar.setTime(date);</TD></TR><TR><TD CLASS="l">668</TD><TD> </TD></TR><TR><TD CLASS="l">669</TD><TD>                                // Create description object</TD></TR><TR><TD CLASS="l">670</TD><TD>                                </TD></TR><TR><TD CLASS="l">671</TD><TD>                                // modification cause: gets the description from the</TD></TR><TR><TD CLASS="l">672</TD><TD>                                // weather_config.xml using the description code</TD></TR><TR CLASS="c"><TD CLASS="l">673</TD><TD>                                String descriptionValue = xmlManager.getValueFromXmlDocument(</TD></TR><TR CLASS="c"><TD CLASS="l">674</TD><TD>                                                &#34;weatherdescriptions&#34;,</TD></TR><TR CLASS="c"><TD CLASS="l">675</TD><TD>                                                Integer.toString(weatherData.getWeatherCode()),</TD></TR><TR CLASS="c"><TD CLASS="l">676</TD><TD>                                                language.getReadableValue());</TD></TR><TR CLASS="c"><TD CLASS="l">677</TD><TD>                                logger.debug(&#34;weather description value from xml: &#34;</TD></TR><TR CLASS="c"><TD CLASS="l">678</TD><TD>                                                + descriptionValue);</TD></TR><TR CLASS="c"><TD CLASS="l">679</TD><TD>                                Value[] weatherDescription = weatherData.getWeatherDesc();</TD></TR><TR><TD CLASS="l">680</TD><TD> </TD></TR><TR><TD CLASS="l">681</TD><TD>                                // Create weather object</TD></TR><TR><TD CLASS="l">682</TD><TD>                                </TD></TR><TR><TD CLASS="l">683</TD><TD>                                // modification cause: converts the date to the correct format</TD></TR><TR><TD CLASS="l">684</TD><TD>                                // depending on the chosen language</TD></TR><TR CLASS="c"><TD CLASS="l">685</TD><TD>                                String formatDate = Utils.convertDateToStringLanguageDate(date, language);</TD></TR><TR CLASS="c"><TD CLASS="l">686</TD><TD>                                weather = new Weather(temperature, wind,</TD></TR><TR CLASS="c"><TD CLASS="l">687</TD><TD>                                                getIcon(weatherDescription[0].getValue()),</TD></TR><TR CLASS="c"><TD CLASS="l">688</TD><TD>                                                descriptionValue, weatherData.getPrecipMM(), formatDate);</TD></TR><TR><TD CLASS="l">689</TD><TD> </TD></TR><TR><TD CLASS="l">690</TD><TD>                        }</TD></TR><TR><TD CLASS="l">691</TD><TD> </TD></TR><TR CLASS="z"><TD CLASS="l">692</TD><TD>                } catch (ParseException e) {</TD></TR><TR CLASS="z"><TD CLASS="l">693</TD><TD>                        logger.error(e.getMessage());</TD></TR><TR CLASS="z"><TD CLASS="l">694</TD><TD>                        throw new WeatherException(e.getMessage(), e.getCause());</TD></TR><TR><TD CLASS="l">695</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">696</TD><TD>                logger.debug(&#34;Exit: getWeather(WeatherData weatherData)&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">697</TD><TD>                return weather;</TD></TR><TR><TD CLASS="l">698</TD><TD>        }</TD></TR><TR><TD CLASS="l">699</TD><TD> </TD></TR><TR><TD CLASS="l">700</TD><TD>}</TD></TR></TABLE><P></P><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="nv">[<A HREF="../Cobertura.html">all classes</A>][<A HREF="3.html">es.citic.puedes.weatherservice.impl</A>]</TD></TR><TR><TD CLASS="tl"><A HREF="http://www.eclemma.org/support.html">EMMA 2.0.5312 EclEmma Fix 2</A> (C) Vladimir Roubtsov</TD></TR></TABLE></BODY></HTML>